package org.dizem.minichat.util;

import sun.misc.BASE64Encoder;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * User: DIZEM
 * Time: 11-3-26 下午4:11
 */
public class Utils {

	public static String encodeByMD5(String str) {
		try {
			MessageDigest md5 = MessageDigest.getInstance("MD5");
			return new BASE64Encoder().encode(md5.digest(str.getBytes("utf-8")));
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return null;
	}

}
